package com.hotel.api.controller;

import com.hotel.api.mapper.UserMapper;

import com.hotel.api.utils.JSONResult;
import com.hotel.api.utils.UploadFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * 测试Controller
 *
 * @Author 涛涛
 * @Create 2019/8/29
 */
@RestController
public class TestController {

    @RequestMapping("/fileUpload")
    public JSONResult upload(@RequestParam("file") MultipartFile file){
        String fileName = "Empty";
        if (!file.isEmpty()){
            // 上传成功，给出页面提示
            fileName = UploadFile.getFilePath(file);
            return JSONResult.ok("上传成功"+"文件名：" + fileName);
        }else {
            return JSONResult.errorMsg("上传失败");
        }
    }

}

